@@ -21,6 +21,9 @@ DATABASE_PASSWORD= |
||
21 | 21 |
|
22 | 22 |
# ==== Additional required production settings ==== |
23 | 23 |
|
24 |
+# Configure Rails environment |
|
25 |
+RAILS_ENV=development |
|
26 |
+ |
|
24 | 27 |
# Outgoing email settings. To use Gmail or Google Apps, put your Google Apps domain or gmail.com |
25 | 28 |
# as the SMTP_DOMAIN and your Gmail username and password as the SMTP_USER_NAME and SMTP_PASSWORD. |
26 | 29 |
SMTP_DOMAIN=your-domain-here.com |
@@ -17,6 +17,7 @@ gem "daemons" |
||
17 | 17 |
# gem "delayed_job_web" |
18 | 18 |
|
19 | 19 |
gem 'foreman' |
20 |
+gem 'dotenv-rails', :groups => [:development, :test] |
|
20 | 21 |
|
21 | 22 |
group :assets do |
22 | 23 |
gem 'sass-rails', '~> 3.2.3' |
@@ -66,6 +66,9 @@ GEM |
||
66 | 66 |
railties (~> 3.1) |
67 | 67 |
warden (~> 1.2.1) |
68 | 68 |
diff-lcs (1.2.1) |
69 |
+ dotenv (0.6.0) |
|
70 |
+ dotenv-rails (0.6.0) |
|
71 |
+ dotenv (= 0.6.0) |
|
69 | 72 |
em-http-request (1.0.3) |
70 | 73 |
addressable (>= 2.2.3) |
71 | 74 |
cookiejar |
@@ -259,6 +262,7 @@ DEPENDENCIES |
||
259 | 262 |
delayed_job! |
260 | 263 |
delayed_job_active_record (~> 0.3.3) |
261 | 264 |
devise |
265 |
+ dotenv-rails |
|
262 | 266 |
em-http-request |
263 | 267 |
fastercsv |
264 | 268 |
foreman |
@@ -1,4 +1,11 @@ |
||
1 |
+# Procfile for development: |
|
1 | 2 |
web: bundle exec rails server |
2 | 3 |
schedule: bundle exec rails runner bin/schedule.rb |
3 | 4 |
twitter: bundle exec rails runner bin/twitter_stream.rb |
4 |
-dj: bundle exec script/delayed_job run |
|
5 |
+dj: bundle exec script/delayed_job run |
|
6 |
+ |
|
7 |
+# Possible Profile configuration for production: |
|
8 |
+# web: bundle exec unicorn -c config/unicorn/production.rb |
|
9 |
+# schedule: bundle exec rails runner bin/schedule.rb |
|
10 |
+# twitter: bundle exec rails runner bin/twitter_stream.rb |
|
11 |
+# dj: bundle exec script/delayed_job run |
@@ -1,3 +1,7 @@ |
||
1 |
+# This is an example Capistrano deployment script for Huginn. It |
|
2 |
+# assumes you're running on an Ubuntu box and want to use Foreman, |
|
3 |
+# Upstart, and Unicorn. |
|
4 |
+ |
|
1 | 5 |
default_run_options[:pty] = true |
2 | 6 |
|
3 | 7 |
set :application, "huginn" |
@@ -12,11 +16,8 @@ set :deploy_via, :remote_cache |
||
12 | 16 |
set :keep_releases, 5 |
13 | 17 |
|
14 | 18 |
set :bundle_without, [:development] |
15 |
-set :unicorn_pid, "#{shared_path}/pids/unicorn.pid" |
|
16 |
- |
|
17 |
-server "yourdomain.com", :app, :delayed_job, :web, :db, :primary => true |
|
18 | 19 |
|
19 |
-set :delayed_job_server_role, :delayed_job |
|
20 |
+server "yourdomain.com", :app, :web, :db, :primary => true |
|
20 | 21 |
|
21 | 22 |
set :sync_backups, 3 |
22 | 23 |
|
@@ -25,24 +26,44 @@ after 'deploy', 'deploy:cleanup' |
||
25 | 26 |
|
26 | 27 |
set :bundle_without, [:development, :test] |
27 | 28 |
|
28 |
-after 'deploy:stop', 'delayed_job:stop' |
|
29 |
-after 'deploy:start', 'delayed_job:start' |
|
30 |
-after 'deploy:restart', 'delayed_job:restart' |
|
31 |
-after 'deploy:update_code', 'deploy:symlink_env_config' |
|
29 |
+after 'deploy:update_code', 'deploy:symlink_configs' |
|
30 |
+after 'deploy:update', 'foreman:export' |
|
31 |
+after 'deploy:update', 'foreman:restart' |
|
32 | 32 |
|
33 | 33 |
namespace :deploy do |
34 |
- desc 'Link the environment file from shared/config/.env into the new deploy directory' |
|
35 |
- task :symlink_env_config, :roles => :app do |
|
34 |
+ desc 'Link the .env environment and Procfile from shared/config into the new deploy directory' |
|
35 |
+ task :symlink_configs, :roles => :app do |
|
36 | 36 |
run <<-CMD |
37 | 37 |
cd #{latest_release} && ln -nfs #{shared_path}/config/.env #{latest_release}/.env |
38 | 38 |
CMD |
39 |
+ |
|
40 |
+ run <<-CMD |
|
41 |
+ cd #{latest_release} && ln -nfs #{shared_path}/config/Procfile #{latest_release}/Procfile |
|
42 |
+ CMD |
|
39 | 43 |
end |
40 | 44 |
end |
41 | 45 |
|
42 |
-# If you want to use command line options, for example to start multiple workers, |
|
43 |
-# define a Capistrano variable delayed_job_args: |
|
44 |
-# |
|
45 |
-# set :delayed_job_args, "-n 2" |
|
46 |
+namespace :foreman do |
|
47 |
+ desc "Export the Procfile to Ubuntu's upstart scripts" |
|
48 |
+ task :export, :roles => :app do |
|
49 |
+ run "cd #{latest_release} && rvmsudo bundle exec foreman export upstart /etc/init -a #{application} -u #{user} -l #{deploy_to}/upstart_logs" |
|
50 |
+ end |
|
51 |
+ |
|
52 |
+ desc 'Start the application services' |
|
53 |
+ task :start, :roles => :app do |
|
54 |
+ sudo "sudo start #{application}" |
|
55 |
+ end |
|
56 |
+ |
|
57 |
+ desc 'Stop the application services' |
|
58 |
+ task :stop, :roles => :app do |
|
59 |
+ sudo "sudo stop #{application}" |
|
60 |
+ end |
|
61 |
+ |
|
62 |
+ desc 'Restart the application services' |
|
63 |
+ task :restart, :roles => :app do |
|
64 |
+ run "sudo start #{application} || sudo restart #{application}" |
|
65 |
+ end |
|
66 |
+end |
|
46 | 67 |
|
47 | 68 |
# If you want to use rvm on your server and have it maintained by Capistrano, uncomment these lines: |
48 | 69 |
# set :rvm_ruby_string, '1.9.3-p286@huginn' |
@@ -55,6 +76,4 @@ end |
||
55 | 76 |
Dir[File.expand_path("../../lib/capistrano/*.rb", __FILE__)].each{|f| load f } |
56 | 77 |
|
57 | 78 |
require "bundler/capistrano" |
58 |
-require "capistrano-unicorn" |
|
59 |
-require "delayed/recipes" |
|
60 | 79 |
load 'deploy/assets' |